import getOneDisputedInfo from "./getOneDisputedInfo";
import handlePK from "./handlePK";
import heanleAllpks from "./handleAllpks";

const urls = {
    'add': '/nccloud/hrcm/dispited/DisputedSaveAction.do'
};

export default function initCardForm(type) {
    const {page} = this.state;
    const {form, button} = this.props;
    // const optionData = this.props.editTable.getAllRows('disputedlist', true);
    let optionData = heanleAllpks.get();
    if (page === 'add') {
        if(type === 'saveAdd'){
            form.setFormStatus('detail', 'browse');
        }
        form.EmptyAllFormValue('detail');
        form.setFormStatus('detail', 'add');
        button.setMainButton({'save':false,'saveAdd': true});
    } else if (page === 'edit' || page === 'detail') {
        if( (optionData && optionData.length > 0)){
            getOneDisputedInfo.call(this, () => {
                if (page === 'detail') {
                    //设置卡片浏览状态
                    form.setFormStatus('detail', 'browse');
                    this.props.cardPagination.setCardPaginationVisible('cardPaginationBtn', true);
                    this.props.cardPagination.setCardPaginationId({id:handlePK.get(),status:1});
                }
            });
        }else{
            if (page === 'detail') {
                //设置卡片浏览状态
                form.setFormStatus('detail', 'browse');
                this.props.cardPagination.setCardPaginationVisible('cardPaginationBtn', true);
                this.props.cardPagination.setCardPaginationId ({id:handlePK.get(),status:1});
            }
        }
        button.setMainButton({'save':true,'saveAdd': false});
    } else {
        form.setFormStatus('detail', 'browse');//设置卡片浏览状态
        //getOneSignCorpInfo.call(this);
    }

}

